<template>
	<!-- 首页-搜索右边的消息 -->
	<view class="msgContent public">
		<view class="content" v-for="(item,index) in msgList.list" 
		:key="index" @click="goDetail(item)" v-if="count>0">
			<view class="title">
				{{item.title}}
			</view>
			<view class="date">
				{{item.create_time | formatTime}}
			</view>
			<view class="msg">
				{{item.content}}
			</view>
		</view>
		<view class="icon-box-img" v-if="count == 0">
			<image src="../../static/index/noResult.png" mode=""></image>
			<view class="text">
				还没有消息
			</view>
		</view>
	</view>
</template>

<script>
	const $api = require('@/utils/request.js').API
	export default {
		data() {
			return {
				msgList:[],
				count: 0,
			}
		},
		onLoad() {
			this.messageList()
		},
		methods: {
			messageList(){
				$api.postMessageList({}).then(res => {
					this.msgList = res.data.data
					this.count = res.data.data.count
				})
			},
			goDetail(item) {
				uni.navigateTo({
					url:'msgDetail?id=' + item.id
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.msgContent{
		background: #FBFBFB;
		overflow-y: scroll;
	}
	.content{
		padding: 30rpx 78rpx 20rpx 40rpx;
		background: #FFFFFF;
		margin-top: 10rpx;
	}
	.title{
		font-size: 34rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #222222;
	}
	.date{
		margin-top: 28rpx;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #818181;
	}
	.msg{
		margin-top: 15rpx;
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #818181;
		line-height: 38rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		-webkit-line-clamp: 3;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}
	.icon-box-img {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		margin-top: 80rpx;

		img {
			width: 343rpx;
			height: 306rpx;
		}

		image {
			width: 343rpx;
			height: 306rpx;
		}

		.text {
			margin-top: 35rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #C3C4C4;
			line-height: 30rpx;
		}
	}
</style>
